package com.lune.job.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.framework.exception.TokenException;
import com.lune.job.framework.redis.RedisUtil;
import com.lune.job.mapper.UserDataMapper;
import com.lune.job.pojo.RespBean;
import com.lune.job.service.IUserDataService;
import com.lune.job.utils.UserThreadLocal;
import com.lune.job.vo.UserData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 *
 **/
@Service
public class UserDataServiceImpl extends ServiceImpl<UserDataMapper,UserData> implements IUserDataService {

    @Autowired
    private RedisUtil redisUtil;

    //返回userData
    public UserData  getUserData() {
        String token = UserThreadLocal.get();   //获取token
        UserData userData  = (UserData) redisUtil.get(token);
        if (userData!=null){
            return userData;
        }else{
           throw new TokenException("超时或者不合法的token");
        }

    }

}
